package com.fyzk.activity.forum;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanxs11 on 17/5/9.
 */

public class TopicListBean implements Serializable {


    /**
     * question_id : 17
     * question_content : 测试测试fdhshfd
     * question_detail : 哈哈哈哈fdsfdsf
     * add_time : 1492106106
     * update_time : 1494216060
     * published_uid : 4
     * answer_count : 1
     * view_count : 2
     * focus_count : 1
     * comment_count : 0
     * action_history_id : 0
     * category_id : 1
     * agree_count : 0
     * against_count : 0
     * best_answer : 0
     * has_attach : 0
     * unverified_modify_count : 0
     * ip : 2130706433
     * last_answer : 23
     * popular_value : 1
     * popular_value_update : 1494222449
     * lock : 0
     * anonymous : 0
     * thanks_count : 0
     * sort : 0
     * post_type : question
     * category_info : {"id":1,"title":"默认分类","type":"question","icon":null,"parent_id":0,"sort":0,"url_token":1}
     * topics : [{"topic_id":3,"topic_title":"双色球"}]
     * user_info : {"uid":4,"user_name":"lele001","mobile":"15201159226","sex":0}
     */

    private int question_id;
    private String question_content;
    private String question_detail;
    private long add_time;
    private long update_time;
    private int published_uid;
    private int answer_count;
    private int view_count;
    private int focus_count;
    private int comment_count;
    private int action_history_id;
    private int category_id;
    private int agree_count;
    private int against_count;
    private int has_attach;
    private int unverified_modify_count;
    private int last_answer;
    private int popular_value_update;
    private int lock;
    private int anonymous;
    private int thanks_count;
    private int sort;
    private String attachs;
    private String[] attachs_ids;
    private String post_type;

    public List<ImageBean> getImageBeens() {
        List<ImageBean> imageBeens = new ArrayList<>();
        try {
            JSONObject object = new JSONObject(getAttachs());
            for (int i = 0; i < getAttachs_ids().length; i++) {
                if (object.has(getAttachs_ids()[i])) {
                    JSONObject imgObject = object.getJSONObject(getAttachs_ids()[i]);
                    ImageBean imageBean = new ImageBean(imgObject.getInt("id"), imgObject.getString("attachment"), imgObject.getString("thumb"));
                    imageBean.width = imgObject.getInt("img_width");
                    imageBean.height = imgObject.getInt("img_height");
                    imageBeens.add(imageBean);
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (Exception e) {

        }
        return imageBeens;
    }

    class ImageBean {
        int id;
        String attachment;
        String thumb;
        int width;
        int height;

        public ImageBean(int id, String attachment, String thumb) {
            this.id = id;
            this.attachment = attachment;
            this.thumb = thumb;
        }
    }

    /**
     * id : 1
     * title : 默认分类
     * type : question
     * icon : null
     * parent_id : 0
     * sort : 0
     * url_token : 1
     */

    private CategoryInfoBean category_info;
    /**
     * uid : 4
     * user_name : lele001
     * mobile : 15201159226
     * sex : 0
     */

    private UserInfoBean user_info;
    /**
     * topic_id : 3
     * topic_title : 双色球
     */

    private List<TopicsBean> topics;

    public int getQuestion_id() {
        return question_id;
    }

    public void setQuestion_id(int question_id) {
        this.question_id = question_id;
    }

    public String getQuestion_content() {
        return question_content;
    }

    public void setQuestion_content(String question_content) {
        this.question_content = question_content;
    }

    public String getQuestion_detail() {
        return question_detail;
    }

    public void setQuestion_detail(String question_detail) {
        this.question_detail = question_detail;
    }

    public long getAdd_time() {
        return add_time;
    }

    public void setAdd_time(long add_time) {
        this.add_time = add_time;
    }

    public long getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(long update_time) {
        this.update_time = update_time;
    }

    public int getPublished_uid() {
        return published_uid;
    }

    public void setPublished_uid(int published_uid) {
        this.published_uid = published_uid;
    }

    public int getAnswer_count() {
        return answer_count;
    }

    public void setAnswer_count(int answer_count) {
        this.answer_count = answer_count;
    }

    public int getView_count() {
        return view_count;
    }

    public void setView_count(int view_count) {
        this.view_count = view_count;
    }

    public int getFocus_count() {
        return focus_count;
    }

    public void setFocus_count(int focus_count) {
        this.focus_count = focus_count;
    }

    public int getComment_count() {
        return comment_count;
    }

    public void setComment_count(int comment_count) {
        this.comment_count = comment_count;
    }

    public int getAction_history_id() {
        return action_history_id;
    }

    public void setAction_history_id(int action_history_id) {
        this.action_history_id = action_history_id;
    }

    public int getCategory_id() {
        return category_id;
    }

    public void setCategory_id(int category_id) {
        this.category_id = category_id;
    }

    public int getAgree_count() {
        return agree_count;
    }

    public void setAgree_count(int agree_count) {
        this.agree_count = agree_count;
    }

    public int getAgainst_count() {
        return against_count;
    }

    public void setAgainst_count(int against_count) {
        this.against_count = against_count;
    }

    public int getHas_attach() {
        return has_attach;
    }

    public void setHas_attach(int has_attach) {
        this.has_attach = has_attach;
    }

    public int getUnverified_modify_count() {
        return unverified_modify_count;
    }

    public void setUnverified_modify_count(int unverified_modify_count) {
        this.unverified_modify_count = unverified_modify_count;
    }

    public int getLast_answer() {
        return last_answer;
    }

    public void setLast_answer(int last_answer) {
        this.last_answer = last_answer;
    }

    public int getPopular_value_update() {
        return popular_value_update;
    }

    public void setPopular_value_update(int popular_value_update) {
        this.popular_value_update = popular_value_update;
    }

    public int getLock() {
        return lock;
    }

    public void setLock(int lock) {
        this.lock = lock;
    }

    public int getAnonymous() {
        return anonymous;
    }

    public void setAnonymous(int anonymous) {
        this.anonymous = anonymous;
    }

    public int getThanks_count() {
        return thanks_count;
    }

    public void setThanks_count(int thanks_count) {
        this.thanks_count = thanks_count;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    public String getAttachs() {
        return attachs;
    }

    public void setAttachs(String attachs) {
        this.attachs = attachs;
    }

    public String[] getAttachs_ids() {
        return attachs_ids;
    }

    public void setAttachs_ids(String[] attachs_ids) {
        this.attachs_ids = attachs_ids;
    }

    public String getPost_type() {
        return post_type;
    }

    public void setPost_type(String post_type) {
        this.post_type = post_type;
    }

    public CategoryInfoBean getCategory_info() {
        return category_info;
    }

    public void setCategory_info(CategoryInfoBean category_info) {
        this.category_info = category_info;
    }

    public UserInfoBean getUser_info() {
        return user_info;
    }

    public void setUser_info(UserInfoBean user_info) {
        this.user_info = user_info;
    }

    public List<TopicsBean> getTopics() {
        return topics;
    }

    public void setTopics(List<TopicsBean> topics) {
        this.topics = topics;
    }

    public static class CategoryInfoBean implements Serializable {
        private int id;
        private String title;
        private String type;
        private Object icon;
        private int parent_id;
        private int sort;
        private int url_token;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public Object getIcon() {
            return icon;
        }

        public void setIcon(Object icon) {
            this.icon = icon;
        }

        public int getParent_id() {
            return parent_id;
        }

        public void setParent_id(int parent_id) {
            this.parent_id = parent_id;
        }

        public int getSort() {
            return sort;
        }

        public void setSort(int sort) {
            this.sort = sort;
        }

        public int getUrl_token() {
            return url_token;
        }

        public void setUrl_token(int url_token) {
            this.url_token = url_token;
        }
    }

    public static class UserInfoBean implements Serializable {
        private int uid;
        private String user_name;
        private String mobile;
        private int sex;
        private String avatar_file;
        private String alias;

        public int getUid() {
            return uid;
        }

        public void setUid(int uid) {
            this.uid = uid;
        }

        public String getUser_name() {
            return user_name;
        }

        public String getAlias() {
            return alias;
        }

        public void setAlias(String alias) {
            this.alias = alias;
        }

        public void setUser_name(String user_name) {
            this.user_name = user_name;
        }

        public String getMobile() {
            return mobile;
        }

        public void setMobile(String mobile) {
            this.mobile = mobile;
        }

        public int getSex() {
            return sex;
        }

        public void setSex(int sex) {
            this.sex = sex;
        }

        public String getAvatar_file() {
            return avatar_file;
        }

        public void setAvatar_file(String avatar_file) {
            this.avatar_file = avatar_file;
        }
    }

    public static class TopicsBean implements Serializable {
        private int topic_id;
        private String topic_title;

        public int getTopic_id() {
            return topic_id;
        }

        public void setTopic_id(int topic_id) {
            this.topic_id = topic_id;
        }

        public String getTopic_title() {
            return topic_title;
        }

        public void setTopic_title(String topic_title) {
            this.topic_title = topic_title;
        }
    }
}
